package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeoutException;

/**
 * 死信队列  实战
 * <p>
 * <p>
 * 消费者1
 */
public class Consumer02 {
    //普通交换机的名词
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    //死信交换机的名称
    public static final String DEAD_EXCHANGE = "dead_exchange";

    //普通队列的名称
    public static final String NORMAL_QUEUE = "normal_queue";

    //死信队列的名称
    public static final String DEAD_QUEUE = "dead_queue";


    public static void main(String[] args) throws IOException, TimeoutException {

        Channel channel = RabbitMqUtils.getChanner();
        channel.exchangeDeclare(DEAD_EXCHANGE, BuiltinExchangeType.DIRECT);

        System.out.println("等待接收消息......");

        DeliverCallback deliverCallback = (consumerTage, message) -> {
            System.out.println("Consumer02接收的消息是:" + new String(message.getBody(), "UTF-8"));
        };

        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, (consumerTage) -> {
        });


    }


}